package verify;

import java.text.DateFormat;
import java.text.SimpleDateFormat;

public class MyVerify {
	
	public final static String SUCCESS = "success";
	
	public String verifyString(String name){
		if ("".equals(name)) {
			return " can not be null";
		}
		return SUCCESS;
	}
	
	public String verifyDouble(String name){
		try {
			Double.parseDouble(name);
			return SUCCESS;
		} catch (Exception e) {
			return " should be double";
		}
	}
	
	public String verifyDate(String name){
		DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
		try{
			dateFormat.parse(name);
			return SUCCESS;
		}catch(Exception e){
			return " should be Date";
		}
	}
	
	public String verifyBoolean(String name){
		try{
			if ("true".equals(name)||"false".equals(name)) {
				return SUCCESS;
			}
			return " should be boolean";
		}catch(Exception e){
			return " should be boolean";
		}
	}
	public String verifyInteger(String name){
		try{
			Integer.valueOf(name);
			return SUCCESS;
		}catch(Exception e){
			return " should be int";
		}
	}

}
